home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YDISK.C
< prev
next >
Wrap
Text File
|
1988-12-08
|
10KB
|
362 lines
/******************************** YDisk.C: **********************************/
/*********************** (C) 1986,7,8 by JAMES A. YORKE **********************/
#include "yinclud.h"
#include <ctype.h>
/* GETDISKFILENAME - take the letters (lower case) and digits out of
* MapName[] and puts it into DDfile[], substituting caps for lower cases;
* then ".PIC" is appended; characters other than letters and digits in
* MapName are ignored, though I guess there cannot be anything else.
* Note: Unix version does not map upper to lower case.
*/
GetDiskFileName()
{
#ifndef UNIX
int J;
char *dfn, ch;
#endif
(void) strcpy(DDfile, DiskFileName);
#ifndef UNIX
dfn = DiskFileName;
for(J = 0; J < 8 && (ch = MapName[J]) != '\0'; J++) {
if(isalnum(ch)) {
if(isdigit(ch))
*dfn++ = ch;
else
*dfn++ = (islower(ch) ? _toupper(ch) : ch);
} else
*dfn++ = ch;
}
(void) strcat(DiskFileName, ".PIC");
#else
(void) strcat(strcpy(DiskFileName, MapName), ".pic");
#endif
return;
}
/* sets the diskdump file name to be the same
* as MapName except that it ends in .DD instead of the old ending
*/
NameDDfile()
{
#ifdef BAD
#ifndef UNIX
(void) strcat(strcpy(DDfile, MapName), ".DD");
#else
(void) strcat(strcpy(DDfile, MapName), ".dd");
#endif
#endif /* BAD */
char *dot,*strcpy();
strcpy(DDfile,DiskFileName);
dot = DDfile;
while(*dot != '.' && *dot != '\0') /* find address of point of end
of string, whichever comes first */
dot++;
dot[0] = '.';
dot[1] = 'D';
dot[2] = 'D';
dot[3] = 0;/* 0 means end of string */
return;
}
DumpData(fff) /* THIS COMMENT SEEMS INCORRECT: this takes the
file name DiskFileName and puts it in the
string DDfile, except with the ending ".DD"
plus a 0 for the end of the string; then it
dumps the current values with their commands
into that diskfile */
FILE * fff;
{
double x,
X,
yval, /* Y is global */
Y;
int ss,
i,
numL;
fprintf(fff,
"%s /* process from map menu */\n", MapName);
if(VertLine != 0)
fprintf(fff,
"VERTLINE %d /* for basin boundaries */\n", VertLine);
if(num_lyap != -9999) /* this should come before dot because "L" sets
dot = 0 */
if(storeNumLyap != 0 || num_lyap != 0) {
if(num_lyap != 0)
numL = num_lyap;
else
numL = storeNumLyap;
fprintf(fff,
"L %d /* number of Lyapunov exponents */\n", numL);
fprintf(fff,
"LYAPTIME %15.15lf /* for internal use */ \n", lyaptime);
fprintf(fff,
"LYAPSTEP %15.15lf \n", lyapstep);
fprintf(fff,
"LYAPSUM ");
for(i = 0; i < numL; i++)
/* for re-initializing vector lyapsum */
fprintf(fff, " %15.15lf \n ", lyapsum[i]);
}
fprintf(fff,
"DOT %ld /* current dot number */\n", dot);
if(dots != 100000000)
fprintf(fff,
"DOTS %ld /* maximum number of dots */\n", dots);
if(preiter != 0)
fprintf(fff,
"PI %ld /* Pre-Iterates before plotting */ \n", preiter);
if(TDFreq != 0)
fprintf(fff,
"TDFREQ %ld /* dots per TD call: saving picture on disk */\n", TDFreq);
if(C1 != -9999)
fprintf(fff,
"C1 %15.15lf \n", C1);
if(C2 != -9999)
fprintf(fff,
"C2 %15.15lf \n", C2);
if(C3 != -9999)
fprintf(fff,
"C3 %15.15lf \n", C3);
if(C4 != -9999)
fprintf(fff,
"C4 %15.15lf \n", C4);
if(C5 != -9999)
fprintf(fff,
"C5 %15.15lf \n", C5);
if(C6 != -9999)
fprintf(fff,
"C6 %15.15lf \n", C6);
if(C7 != -9999)
fprintf(fff,
"C7 %15.15lf \n", C7);
if(C8 != -9999)
fprintf(fff,
"C8 %15.15lf \n", C8);
if(C9 != -9999)
fprintf(fff,
"C9 %15.15lf \n", C9);
if(rho != -9999)
fprintf(fff,
"R %15.15lf /* rho */ \n", rho);
if(beta != -9999)
fprintf(fff,
"beta %15.15lf \n", beta);
if(sigma != -9999)
fprintf(fff,
"sigma %15.15lf \n", sigma);
if(rho_final != rho)
fprintf(fff,
"FR\n %15.15lf /* final rho */\n", rho_final);
if(rho_step != 1.)
fprintf(fff,
"RS %15.15lf /* rho step */\n", rho_step);
for(ss = 0; ss < 5; ss++)
if(xScrPix[ss] != -9999.&& xScrPix[ss] != 0 && yScrPix[ss] != 0) {
/* they can't be 0 anyway */
x = X_Lo[ss];
X = X_Up[ss];
Y = Y_Up[ss];
yval = Y_Lo[ss];
fprintf(fff,
"SSS %d\n %13.13lf %13.13lf %13.13lf %13.13lf \n /* set window */\n"
,ss, x, X, yval, Y);
fprintf(fff,
" SS %d /* window number */\nSD %15.15lf /* set diameter */\n"
,ss, diameters[ss]);
fprintf(fff,
"C %d %d /* set coordinate numbers */\n", ssX_coord[ss], ssY_coord[ss]);
}
if(OldDiameters != -9999)
fprintf(fff,
"OSD %15.15lf \n", OldDiameters);
if(screen_fraction !=.1)
fprintf(fff,
"SF %15.15lf \n/* Screen Fraction = distance arrow keys move small arrow */\n",
screen_fraction);
if(x_old_low != -9999)
fprintf(fff, "OXL %15.15lf \n", x_old_low);
if(x_old_upp != -9999)
fprintf(fff, "OXU %15.15lf \n", x_old_upp);
if(y_old_low != -9999)
fprintf(fff, "OYL %15.15lf \n", y_old_low);
if(y_old_upp != -9999)
fprintf(fff, "OYU %15.15lf \n", y_old_upp);
if(x_new_low != -9999)
fprintf(fff, "NXL %15.15lf \n", x_new_low);
if(x_new_upp != -9999)
fprintf(fff, "NXU %15.15lf \n", x_new_upp);
if(y_new_low != -9999)
fprintf(fff, "NYL %15.15lf \n", y_new_low);
if(y_new_upp != -9999)
fprintf(fff, "NYU %15.15lf \n", y_new_upp);
if(images != 0)
fprintf(fff,
"IMAGES %d \n", images);
if(its_per_plot != -9999 && its_per_plot != 1)
fprintf(fff,
"IPP %d /* iterates per plot */ \n", its_per_plot);
if(steps_per_cycle != -9999)
fprintf(fff,
"SPC %lf /* differential equation steps per cycle of forcing function */\n"
,steps_per_cycle);
if(step != -9999 && step < 0)
fprintf(fff,
"INVERT /* makes differential equation time step negative */ \n");
if(step != -9999)
fprintf(fff,
"STEP %15.15lf /* differential equation time step */ \n", step);
if(cycle != 0)
fprintf(fff,
"PAUSE \n");
if(cross0flag != 0)
fprintf(fff,
"CROSS /* plot cross at each dot */\n");
if(ticFlag != 0)
fprintf(fff,
"TIC /* tic marks */ \n");
if(MaxChecks != 2000)
fprintf(fff,
"MC %d /* maximun number of checks */ \n", MaxChecks);
if(rad_attr !=.1)
fprintf(fff,
"RA %lf /* radius of attraction */\n", rad_attr);
if(IsClose !=.00000001)
fprintf(fff,
"SDIST %15.15lf /* straddle pair distance */ \n", IsClose);
if(BST_switch != 0)
fprintf(fff,
"bstswitch %d /* for Basin Straddle Trajectory */ \n", BST_switch);
if(divisions != 30)
fprintf(fff,
"DIV %d /* number of divisions in refining saddle straddle pair */\n"
,divisions);
if(printer != 3)
fprintf(fff,
"PT %d /* set quantity of screen comments and printout data */ \n", printer);
if(onprint != 0)
fprintf(fff,
"PH %d /* number of times printer head strikes for each dot */\n", onprint);
fprintf(fff,
"SS %d /* current window number */\n", ScrnSec);
fprintf(fff,
"XS %15.15lf %15.15lf /* X Scale */ \n", X_lower, X_upper);
fprintf(fff,
"YS %15.15lf %15.15lf /* Y Scale */ \n", Y_lower, Y_upper);
if(disk != 0)
fprintf(fff,
"TDWP /* To DIsk When Printing */\n");
if(boxx != 0)
fprintf(fff,
"DB /* draw box */\n");
if(plotFlag == 1)
fprintf(fff,
"CONNECT \n");
if(period != 1)
fprintf(fff,
"NP %d /* Newton Period */ \n", period);
fprintf(fff,
"DN %s /* Disk File name for saving pictures */ \n", DiskFileName);
fprintf(fff,
"f9 %d /* set color */ \n", color);
if(frac != 0)
fprintf(fff,
"FRAC %15.15lf /* for stable and unstable manifolds */ \n", frac);
if(add != 0)
fprintf(fff,
"ADD %15.15lf /* for stable and unstable manifolds */ \n", add);
if(length != 0)
fprintf(fff,
"LENGTH %15.15lf /* for stable and unstable manifolds */ \n", length);
if(iter != 0)
fprintf(fff,
"ITER %d /* for stable and unstable manifolds */ \n", iter);
if(goodIterate != 0)
fprintf(fff,
"GOODITERATE %d /* for stable and unstable manifolds */ \n", goodIterate);
if(oldGoodIt != 0)
fprintf(fff,
"OLDGOODIT %d /* for stable and unstable manifolds */ \n", oldGoodIt);
DumpYs(fff);
printTimes(fff); /* for runtime and tdtime -- see Y.c */
bifdisk(fff); /* in YBIFM.C for parameters for BIF */
fprintf(fff,
"FileEnd\n");
}
DumpYs(fff) /* dumps to file fff all the non trivial
coordinates of each yx[] for which yx[0] is
non trivial */
FILE * fff;
{
char x;
int J,
K;
scr_rowcol(0, 0);
K = NUM_Y;
for(J = 0; J < K; J++) {
x = '0' + J;
DumpDoubleVector(dim, x, fff);
}
for(J = 0; J < 5; J++) {
x = 'a' + J;
DumpDoubleVector(dim, x, fff);
}
}
DumpDoubleVector(dimval, x, fff) /* this routine takes a character x, and
returns if yx[] does not exist; if it does
exist and providing yx[0] != -9999., this
routine transmits to file fff those
coordinates of yx that are not equal to
-9999.; when it does exist and is non
trivial the routine starts transmission with
SV<return> x<return> and the rest of
the transmissions are of the form i<return>
Y[i]<return> and the string of transmissions
ends with an extra <return> */
int dimval;
char x;
FILE * fff;
{
int i,
dimen = dimval;
if(dimval > eqn1 && x != '0')
dimen = eqn1;
if(num_lyap == 0 && lyapzero < dimen)
dimen = lyapzero;
if(ChooseStorageVec (x) == 0)/* 0 means not acceptable */
return;
/* ChooseStorageVector sets pointer ystore_in */
if(ystore_in[0] == -9999.)
return;
else
fprintf(fff, "SV \n%c\n", StorChar);
for(i = 0; i < dimen; i++)
if(ystore_in[i] != -9999.)
fprintf(fff, "%d \n %15.15g \n", i, ystore_in[i]);
fprintf(fff, "\n"); /* indicates end of coordinates */
}